Path

class Path(rawPath: String, resolve: Boolean)

Path handling utilities modeled after JVM's Path and Python's pathlib. By default resolves paths on creation. Disabling this may lead to errors.

Constructors

Path
Link copied to clipboard
fun Path(rawPath: String, resolve: Boolean = true)

Types

Companion
Link copied to clipboard
object Companion

Functions

ancestor
Link copied to clipboard
fun ancestor(great: Int): Path
Repeatedly gets parent.
append
Link copied to clipboard
suspend fun append(data: <ERROR CLASS>, createParents: Boolean = true)
Append data to this file, creating it if it doesn't exist.
suspend fun append(data: ByteArray, createParents: Boolean = true)
Append data to this file, creating it if it doesn't exist.
suspend fun append(data: String, encoding: String? = "utf8", createParents: Boolean = true)
Append data to this file, creating it if it doesn't exist.
appendLine
Link copied to clipboard
suspend fun appendLine(data: String, encoding: String? = "utf8", createParents: Boolean = true)
Append a line to this file (adds lineSeparator to data).
appendLineSync
Link copied to clipboard
fun appendLineSync(data: String, encoding: String? = "utf8", createParents: Boolean = true)
Append a line to this file (adds lineSeparator to data).
appendStream
Link copied to clipboard
fun appendStream(encoding: String? = "utf8", createParents: Boolean = true): <ERROR CLASS>
Create a stream to append to the file.
appendSync
Link copied to clipboard
fun appendSync(data: <ERROR CLASS>, createParents: Boolean = true)
Append data to this file, creating it if it doesn't exist.
fun appendSync(data: ByteArray, createParents: Boolean = true)
Append data to this file, creating it if it doesn't exist.
fun appendSync(data: String, encoding: String? = "utf8", createParents: Boolean = true)
Append data to this file, creating it if it doesn't exist.
contains
Link copied to clipboard
operator fun contains(segment: String): Boolean
See if this path contains a segment.
copy
Link copied to clipboard
suspend fun copy(dest: Path, recursive: Boolean = true, force: Boolean = true)
Copies this file or directory todest.
copyChildrenInto
Link copied to clipboard
suspend fun copyChildrenInto(destDir: Path, recursive: Boolean = true, force: Boolean = true)
Copy this directory's children into the directory destDir, creating it if it does not exist.
copyInto
Link copied to clipboard
suspend fun copyInto(destDir: Path, recursive: Boolean = true, force: Boolean = true)
Copy this file or directory intodestDir, creating it if it does not exist.
delete
Link copied to clipboard
suspend fun delete(recursive: Boolean = false)
Delete this path.
deleteRecursively
Link copied to clipboard
suspend fun deleteRecursively()
Delete this path recursively.
descendant
Link copied to clipboard
fun descendant(rest: Path): Path
Get a descendant.
fun descendant(rest: String): Path
Get a descendant.
div
Link copied to clipboard
operator fun div(rest: Path): Path
Get a descendant.
operator fun div(rest: String): Path
Get a descendant.
equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
open override fun hashCode(): Int
isDescendantOf
Link copied to clipboard
fun isDescendantOf(ancestor: Path): Boolean
Get if this is a descendant of ancestor.
fun isDescendantOf(ancestor: String): Boolean
Get if this is a descendant of ancestor.
mkdir
Link copied to clipboard
fun mkdir(parents: Boolean = true, existsOk: Boolean = true): Path
Make this directory.
move
Link copied to clipboard
suspend fun move(dest: Path, force: Boolean = true)
Move this file or directory todest.
moveChildrenInto
Link copied to clipboard
suspend fun moveChildrenInto(destDir: Path, force: Boolean = true)
Move this directory's children into the directory destDir, creating it if it does not exist.
moveInto
Link copied to clipboard
suspend fun moveInto(destDir: Path, force: Boolean = true)
Move this file or directory intodestDir, creating it if it does not exist.
readBytes
Link copied to clipboard
suspend fun readBytes(): ByteArray
Read this file.
readBytesSync
Link copied to clipboard
fun readBytesSync(): ByteArray
Read this file.
readStream
Link copied to clipboard
fun readStream(encoding: String? = "utf8"): <ERROR CLASS>
Create a stream to read the file.
readText
Link copied to clipboard
suspend fun readText(encoding: String = "utf8"): String
Read this file.
readTextSync
Link copied to clipboard
fun readTextSync(encoding: String = "utf8"): String
Read this file.
rename
Link copied to clipboard
fun rename(newName: String)
Synchronously rename the file or directory, erring if a file or directory already exists with the new name
requireDirectory
Link copied to clipboard
fun requireDirectory(requireExists: Boolean = true): Path
Throw if this path is not a directory, or doesn't exist and requireExists is true (as it is by default).
requireFile
Link copied to clipboard
fun requireFile(requireExists: Boolean = true): Path
Throw if this path is not a file, or doesn't exist and requireExists is true (as it is by default).
resolve
Link copied to clipboard
fun resolve(): Path
Resolve a path.
toString
Link copied to clipboard
open override fun toString(): String
touch
Link copied to clipboard
fun touch(): Path
Create an empty file if it doesn't exist, creating parent directories if necessary.
write
Link copied to clipboard
suspend fun write(data: <ERROR CLASS>, createParents: Boolean = true)
Write to this file, truncating it if it exists, and creating it if not.
suspend fun write(data: ByteArray, createParents: Boolean = true)
Write to this file, truncating it if it exists, and creating it if not.
suspend fun write(data: String, encoding: String? = "utf8", createParents: Boolean = true)
Write to this file, truncating it if it exists, and creating it if not.
writeStream
Link copied to clipboard
fun writeStream(encoding: String? = "utf8", createParents: Boolean = true): <ERROR CLASS>
Create a stream to write the file.
writeSync
Link copied to clipboard
fun writeSync(data: <ERROR CLASS>, createParents: Boolean = true)
Write to this file, truncating it if it exists, and creating it if not.
fun writeSync(data: ByteArray, createParents: Boolean = true)
Write to this file, truncating it if it exists, and creating it if not.
fun writeSync(data: String, encoding: String? = "utf8", createParents: Boolean = true)
Write to this file, truncating it if it exists, and creating it if not.

Properties

children
Link copied to clipboard
val children: List<Path>
Get whether this directory is empty.
exists
Link copied to clipboard
val exists: Boolean
Gets whether this path exists.
extension
Link copied to clipboard
val extension: String
Get the file extension.
isAbsolute
Link copied to clipboard
val isAbsolute: Boolean
Gets whether this path is absolute.
isDir
Link copied to clipboard
val isDir: Boolean
Get whether this path exists and is a directory.
isDirEmpty
Link copied to clipboard
val isDirEmpty: Boolean
Get whether this directory is empty.
isFile
Link copied to clipboard
val isFile: Boolean
Get whether this path exists and is a file.
name
Link copied to clipboard
val name: String
Get the file/directory name (with extension).
parent
Link copied to clipboard
val parent: Path
Get the parent Path.
path
Link copied to clipboard
val path: String
The raw path.
segments
Link copied to clipboard
val segments: List<String>
Get the path segments of this path.
stats
Link copied to clipboard
val stats: <ERROR CLASS>?
Get Stats for this path, if it exists.

Sources

js source
Link copied to clipboard